/* From Careercup.com
 * mplement the bucket tool in MS paint. Bucket tool is the one which fill colors 
 * when we click at any point. You get an input of x n y co-ordinates and the new color to put.
 */
class Paint{
	
	enum Color {
	Black, White, Red, Yellow, Green
	}

	boolean PaintFill(Color[][] screen, int x, int y, Color ocolor,Color ncolor) {
		if (x < 0 || x >= screen[0].length ||y < 0 || y >= screen.length) {
			return false;
		}
		if (screen[y][x] == ocolor) {
			screen[y][x] = ncolor;
			PaintFill(screen, x - 1, y, ocolor, ncolor); // left
			PaintFill(screen, x + 1, y, ocolor, ncolor); // right
			PaintFill(screen, x, y - 1, ocolor, ncolor); // top
			PaintFill(screen, x, y + 1, ocolor, ncolor); // bottom
		}
		return true;
	}

	boolean PaintFill(Color[][] screen, int x, int y, Color ncolor) {
		return PaintFill(screen, x, y, screen[y][x], ncolor);
	}
}